package C;

import java.util.HashMap;
import java.util.Scanner;

public class C1My {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Integer, HashMap<String,Integer>> cnts = new HashMap<>();
        for (int i = 0; i < n; i++){
            String url = sc.next();
            String[] urlComponents = url.split("/");
            for (int level = 0;level < urlComponents.length;level++){
                //if (cnts.size() <= level) { cnts.put(level,new HashMap<>()); }
                cnts.computeIfAbsent(level, k -> new HashMap<>());
                HashMap<String,Integer> map = cnts.get(level);
                map.put(urlComponents[level], map.getOrDefault(urlComponents[level],0)+1);
            }
        }
        int tar_level = sc.nextInt();
        String tar_url = sc.next();
        //
        HashMap<String,Integer> defaultMap = new HashMap<>();
        System.out.println(cnts.getOrDefault(tar_level,defaultMap).getOrDefault(tar_url,0));
    }
}
